<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('附件列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="btn-group-sm" id="toolbar" role="group" th:if="${isView ne '1'}">
            <a class="btn btn-success" onclick="$.operate.add('', '上传附件')" shiro:hasPermission="system:attachment:edit">
                <i class="fa fa-plus"></i> 上传
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:attachment:edit">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var viewFlag = [[${@permission.hasPermi('system:sysAttachment:view')}]];
    var removeFlag = [[${@permission.hasPermi('system:sysAttachment:edit')}]];
    var prefix = ctx + "system/attachment";
    var mainId = [[${mainId}]];
    var entityName = [[${entityName}]];
    var isView = [[${isView}]];

    $(function () {
        var options = {
            url: prefix + "/list?mainId=" + mainId + "&entityName=" + entityName,
            detailUrl: prefix + "/detail/{id}",
            createUrl: prefix + "/add?mainId=" + mainId + "&entityName=" + entityName,
            removeUrl: prefix + "/remove",
            modalName: "附件",
            showExport: false, //工具栏导出
            showToggle: false, //工具栏切换
            showSearch: false, //工具栏查询
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键id',
                    visible: false
                },
                /*{
                 field: 'attachmentId',
                 title: '附件id',
                 sortable: true
                 },
                 {
                 field: 'attachmentRev',
                 title: '附件版本号',
                 sortable: true
                 },*/
                {
                    field: 'attachmentName',
                    title: '附件名称',
                    sortable: false
                },
                {
                    field: 'attachmentType',
                    title: '附件类型',
                    sortable: false
                },
                {
                    field: 'attachmentSize',
                    title: '附件大小',
                    sortable: false,
                    formatter: function (value, row, index) {
                        return $.common.calculateFileSize(row.attachmentSize);
                    }
                },
                {
                    field: 'attachmentPath',
                    title: '附件路径',
                    sortable: false
                },
                {
                    field: 'uploadDate',
                    title: '上传日期',
                    sortable: false
                },
                /*{
                 field: 'downloadStatus',
                 title: '下载状态(0未下载过,1已下载过)',
                 sortable: true
                 },*/
                {
                    field: 'createByName',
                    title: '上传人',
                    sortable: false
                },
                /*{
                 field: 'createTime',
                 title: '创建时间',
                 sortable: true
                 },
                 {
                 field: 'updateTime',
                 title: '更新时间',
                 sortable: true
                 },*/
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + viewFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-search"></i>详细</a>');
                        actions.push('<a class="btn btn-success btn-xs ' + viewFlag + '" href="javascript:void(0)" onclick="$.operate.downloadAttachment(\'' + row.id + '\')"><i class="fa fa-edit"></i>下载</a>');
                        if (isView != '1') {
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>